const fs = require("fs");

var list = [];
var filenames = fs.readdirSync("./scripts/");
filenames.forEach(function(filename) {
    try {
        var item = require("./scripts/" + filename);
        list.push({
            title: item.title,
            url: "./scripts/" + filename,
            description: item.description
        });
    } catch (error) {
        console.log("./scripts/" + filename, error);
    }
});

var text = fs.readFileSync("template.html", "utf8");
text = text.replace('"replace me"', JSON.stringify(list));
fs.writeFileSync("index.html", text);